import Vue from 'vue'
import Router from 'vue-router'
import Login from '../components/Login.vue'
import home from '../components/home.vue'


import publishMeal from '../components/publishMeal.vue'
import SelectStore from '../components/SelectStore.vue'

 Vue.use(Router)

const router = new Router({
	routes: [{
			path: '/',
			redirect: '/login',
		},

		{
			path: '/login',
			meta: [{
				title: "山东省文化和旅游惠民消费季发券平台_登录页面"
			}],
			component: Login,
		},
	
		{
			path: '/selectStore',

			component: SelectStore,
		},

		{
			path: '/publishMeal',
			// name: 'publishMeal',
			// // meta: {
			// // 	keepAlive: true
			// // },
			// meta: [{
			// 	title: "点餐系统",
			// 	path: 'publishMeal',
			// 	keepAlive: true //此页面需要缓存
			// }],
			component: publishMeal
		},

		// {
		// 	path: '/home',
		// 	redirect: '/home/HomeContent',
		// 	component: home,
		// 	children: [
				
		// 		{
		// 			path: 'publishMeal',
		// 			name: 'publishMeal',
		// 			// meta: {
		// 			// 	keepAlive: true
		// 			// },
		// 			meta: [{
		// 				title: "点餐系统",
		// 				path: 'publishMeal',
		// 				keepAlive: true //此页面需要缓存
		// 			}],
		// 			component: publishMeal
		// 		},

 		// 	]
		// }

	]
});
//导航守卫 使用 router.beforeEach 注册一个全局前置守卫，判断用户是否登陆
router.beforeEach((to, from, next) => {
	console.log('xixixixhhhhhh---to',to,'----from---',from);
	if (to.path === '/home/shopContent' && from.path === '/home/shopreview') {
		console.log('嘻嘻为嘻嘻嘻嘻嘻嘻');

	} else {
		// console.log('哈哈哈哈哈哈');
		// 详情返回列表不删除
		// localStorage.removeItem("benefitActivityJson");
	}
	if (to.path === '/login') {
		return next();
	} else {
		//拿浏览器保存的token前面需要加window
		// let token = window.localStorage.getItem('Authorization');
		// if (!token) {
		// 	return next('/login');
		// } else {
		next();
		// }
	}
});
export default router;